#include <basic_types.h>
#include <mediatypes.h>

#include <api/libc/printf.h>
#include <hld/osd/osddrv.h>
#include <api/libsubt/subt_osd.h>
#include <api/libsubt/lib_subt.h>
//#include "osd_lib.h"
#include <hld/hld_dev.h>
#include <hld/sdec/sdec.h>
#include <hld/dis/vpo.h>


struct subt_config_par g_subt_config_par;//
BOOL g_subt_init = FALSE;
struct osd_device *osd_dev;

BOOL g_subt_show_on = FALSE;

unsigned char subt_palette[256][4];
BOOL g_update_palette = FALSE;

UINT32 subt_region_type = 0xFFFFFFFF;

/////////////////////////////////////////////////////////////////////////////////////////////////
void osd_subt_enter()
{
    if(g_subt_init == FALSE)
        return;
    return g_subt_config_par.osd_subt_enter();
}

void osd_subt_leave()
{
    if(g_subt_init == FALSE)
        return;
    return g_subt_config_par.osd_subt_leave();
}

void osd_subt_set_clut(UINT8 entry_id,UINT8 y,UINT8 cb,UINT8 cr,UINT8 t)
{
    if(g_subt_init == FALSE)
        return;
    return g_subt_config_par.osd_subt_set_clut(entry_id, y, cb, cr, t);
}

void osd_subt_clear_page()
{
    if(g_subt_init == FALSE)
        return;
    return g_subt_config_par.osd_subt_clear_page();
}

INT32 osd_subt_create_region(UINT8 region_idx,struct OSDRect *rect)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_create_region(region_idx,rect);
}

INT32 osd_subt_delete_region(UINT8 region_idx)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_delete_region(region_idx);
}
INT32 osd_subt_region_show(UINT8 region_idx,UINT8 on)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_region_show(region_idx, on);
}

INT32 osd_subt_draw_pixel(UINT8 region_idx,UINT16 x,UINT16 y,UINT8 data)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_draw_pixel(region_idx, x, y, data);
}

BOOL osd_region_is_created(UINT8 region_idx)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_region_is_created(region_idx);
}

//void osd_subt_draw_pixelmap(struct OSDRect rect, UINT8* data)
//{
//    if(g_subt_init == FALSE)
//        lib_subt_init();
//    return g_subt_config_par.osd_subt_draw_pixelmap(rect, data);
//}

INT32 osd_subt_get_region_addr(UINT8 region_idx,UINT16 y, UINT32 *addr)
{
    if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_get_region_addr(region_idx, y, addr);
}

void osd_subt_update_clut(void)
{
    if(g_subt_init == FALSE)
        lib_subt_init();
    return g_subt_config_par.osd_subt_update_clut();
}

INT32 osd_subt_display_define(struct sdec_display_config *cfg)
{
	if(g_subt_init == FALSE)
        return 0;
    return g_subt_config_par.osd_subt_display_define(cfg);
}
